<template>
	<view class="tab-bar">
		<view class="tab-bar-item" v-for="(item, index) in tabBarList" :key="index" @click="selectTabBar(item,index)">
			<image class="tab_img" :src="selected === index ? item.selectedIconPath : item.iconPath"></image>
			<view class="tab_text" :class="[selected === index ?'active':'']">{{ item.text }}</view>

			<!-- <view>
					<view class="tab-img">
						<image v-if="routePath === item.pagePath" class="img" :src="item.selectedIconPath"></image>
						<image v-else class="img" :src="item.iconPath"></image>
					</view>
				</view> -->
			<!-- <view v-if="routePath === item.pagePath" class="tit selectTexts">{{ item.text }}</view>
				<view v-else class="tit texts">{{ item.text }}</view> -->
		</view>
	</view>
</template>

<script>
	import data from './tabBar.js'
	export default {
		name: "tabbar-app",
		props:{
			selected: { 
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				tabBarList: [],
				// selected: 0
			};
		},
		created() {
			this.tabBarList = data.member
			// console.log('打印',data.member);			
		},
		methods: {
			selectTabBar(item, index) {
				// this.selected = index
				uni.switchTab({
					url: item.pagePath
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab-bar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		height: 120rpx;
		background: pink;
		display: flex;
		justify-content: center;
		align-items: center;
		padding-bottom: calc(env(safe-area-inset-bottom) / 2); // 适配iphoneX的底部
		z-index: 9999;

		.tab-bar-item {
			flex: 1;
			text-align: center;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;

			.tab_img {
				width: 37rpx;
				height: 41rpx;
			}

			.tab_text {
				font-size: 20rpx;
				margin-top: 9rpx;
				color: #999;
			}

			.active {
				color: black;
			}
		}
	}
</style>